{template 'common/header-storex'}
<div class="wn-main">
	<div class="wn-main__head">商品管理</div>
	<div class="wn-main__content">
		<div class="wn-tabs">
			<div class="wn-tabs__item">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_goodsmanage', array('op' => 'display', 'storeid' => $_GPC['storeid']))}">商品列表</a>
			</div>
			<div class="wn-tabs__item wn-tabs__item--active">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_room_status', array('storeid' => $_GPC['storeid']))}">维护房量/房态</a>
			</div>
			<div class="wn-tabs__item">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_room_price', array('storeid' => $_GPC['storeid']))}">维护房价</a>
			</div>
		</div>
		<div class="panel wn-panel">
			<div class="panel-heading">条件</div>
			<div class="panel-body">
				<form action="./index.php" method="get" class="form-horizontal" role="form">
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">日期范围</label>
						<div class="col-sm-8 col-lg-9">
							{php echo tpl_form_field_daterange('datelimit',array('starttime'=>date('Y-m-d', $startime),'endtime'=>date('Y-m-d', $endtime)))}
							<label class="checkbox-inline">
								<input type="checkbox" name="days_checkall" class='days_checkall' checked/> 全选
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days" value="1" class='days' checked/> 周一
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days"  value="2" class='days' checked/> 周二
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days" value="3"  class='days' checked/> 周三
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days" value="4"  class='days' checked/> 周四
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days"  value="5" class='days' checked/> 周五
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days"  value="6" class='days' checked/> 周六
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="days" value="0" class='days' checked/> 周日
							</label>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">房型选择</label>
						<div class="col-sm-8 col-lg-9">
							<label class="checkbox-inline">
								<input type="checkbox" name="checkall" class='checkall' checked/> 全选
							</label>
							{loop $rooms $r}
							<label class="checkbox-inline">
								<input type="checkbox" name="checkall" class='room' value="{$r['id']}" checked/> {$r['title']}
							</label>
							{/loop}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">房态</label>
						<div class="col-sm-8 col-lg-9">
							<label class="radio-inline">
								<input type="radio" name="status" value="1"/> 开
							</label>
							<label class="radio-inline">
								<input type="radio" name="status" value="0"/> 关
							</label>
						</div>
					</div>
					<div class="form-group">
						<div class=" col-sm-2 col-sm-offset-1 ">
							<button class="btn btn-default" id='create_btn' type='button'><i class="fa fa-search"></i> 生成房量/房态表</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="panel wn-panel">
			<div class="panel-heading">房量/房态表</div>
			<div class="panel-body">
				<div  id="d_list">
				</div>
			</div>
		</div>
	</div>
</div>
<input type="hidden" id="storeid" value="{$storeid}" />
<script type="text/javascript">
	$(function () {
		$(".checkall").click(function(){
			var checked = $(this).get(0).checked;
			$(".room").each(function(){this.checked = checked});
		})
		$(".days_checkall").click(function(){
			var checked = $(this).get(0).checked;
			$(".days").each(function(){this.checked = checked});
		})
		$("#create_btn").click(function () {
			var start = $(":hidden[name='datelimit[start]']").val();
			var end = $(":hidden[name='datelimit[end]']").val();
			var rooms = [];
			var days = [];
			$(".room").each(function(){
				if($(this).get(0).checked){
					rooms.push($(this).val());
				}
			});
			$(".days").each(function(){
				if($(this).get(0).checked){
					days.push($(this).val());
				}
			});
			if (typeof(rooms) == 'undefined' || !rooms.length) {
				util.message('房型必须选择！');
				return;
			}
			if (typeof(days) == 'undefined' || !days.length) {
				util.message('日期必须选择！');
			}
			$("#d_list").html("正在加载...");
			$.post("{php echo $this->createWebUrl('shop_room_status')}", {op : 'updatelot_create', storeid : {$storeid}, rooms : rooms, days : days, start : start, end : end}, function (data) {
				data = eval("(" + data + ")");
				if (data.result == 1) {
					$("#d_list").html(data.code);
				}
			});
		});
	});
</script>
{template 'common/footer'}
